import { useSelector, useDispatch } from "react-redux";
import { increment, asyncincrement } from "../store/features/counterSlice";
const Counter = () => {
    const dispatch = useDispatch();
    const { count } = useSelector((state) => state.counter);
    return (
        <>
            <div className="alert alert-danger">当前数值为：{count}</div>
            <div className="btn-group">
                <button
                    className="btn btn-primary"
                    onClick={() => dispatch(increment(2))}
                >
                    同步增加
                </button>
                <button
                    className="btn btn-danger"
                    onClick={() => dispatch(asyncincrement(3))}
                >
                    异步增加
                </button>
            </div>
        </>
    );
};

export default Counter;
